home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / Developer Essentials Jul 90 / Programming / MPW Interfaces & Libraries 3.1 / CIncludes / MIDI.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-13  |  10.4 KB  |  274 lines  |  [TEXT/MPS ]

  1. /************************************************************
  2.  
  3. Created: Monday, September 18, 1989 at 8:11 PM
  4.     MIDI.h
  5.     C Interface to the Macintosh Libraries
  6.  
  7.  
  8.     
  9.        
  10.         Author: John Worthington, Don Marsh, Mark Lentczner
  11.         Copyright © 1988, Apple Computer, Inc.
  12.         All Rights Reserved
  13.      
  14.  
  15. ************************************************************/
  16.  
  17.  
  18. #ifndef __MIDI__
  19. #define __MIDI__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24.  
  25. #define midiToolNum 4                   /*tool number of MIDI Manager for SndDispVersion call*/
  26. #define midiMaxNameLen 31               /*maximum number of characters in port and client names*/
  27.  
  28. /* Time formats */
  29.  
  30. #define midiFormatMSec 0                /*milliseconds*/
  31. #define midiFormatBeats 1               /*beats*/
  32. #define midiFormat24fpsBit 2            /*24 frames/sec.*/
  33. #define midiFormat25fpsBit 3            /*25 frames/sec.*/
  34. #define midiFormat30fpsDBit 4           /*30 frames/sec. drop-frame*/
  35. #define midiFormat30fpsBit 5            /*30 frames/sec.*/
  36. #define midiFormat24fpsQF 6             /*24 frames/sec. longInt format */
  37. #define midiFormat25fpsQF 7             /*25 frames/sec. longInt format */
  38. #define midiFormat30fpsDQF 8            /*30 frames/sec. drop-frame longInt format */
  39. #define midiFormat30fpsQF 9             /*30 frames/sec. longInt format */
  40. #define midiInternalSync 0              /*internal sync*/
  41. #define midiExternalSync 1              /*external sync*/
  42.  
  43. /*  Port types */
  44.  
  45. #define midiPortTypeTime 0              /*time port*/
  46. #define midiPortTypeInput 1             /*input port*/
  47. #define midiPortTypeOutput 2            /*output port*/
  48. #define midiPortTypeTimeInv 3           /*invisible time port*/
  49.  
  50. /* OffsetTimes  */
  51.  
  52. #define midiGetEverything 0x7FFFFFFF    /*get all packets, regardless of time stamps*/
  53. #define midiGetNothing 0x80000000       /*get no packets, regardless of time stamps*/
  54. #define midiGetCurrent 0x00000000       /*get current packets only*/
  55.  
  56. /*     MIDI data and messages are passed in MIDIPacket records (see below).
  57.     The first byte of every MIDIPacket contains a set of flags
  58.    
  59.     bits 0-1    00 = new MIDIPacket, not continued
  60.                      01 = begining of continued MIDIPacket
  61.                      10 = end of continued MIDIPacket
  62.                     11 = continuation
  63.     bits 2-3     reserved
  64.   
  65.     bits 4-6      000 = packet contains MIDI data
  66.    
  67.                      001 = packet contains MIDI Manager message
  68.    
  69.     bit 7              0 = MIDIPacket has valid stamp
  70.                         1 = stamp with current clock */
  71.  
  72. #define midiContMask 0x03
  73. #define midiNoCont 0x00
  74. #define midiStartCont 0x01
  75. #define midiMidCont 0x03
  76. #define midiEndCont 0x02
  77. #define midiTypeMask 0x70
  78. #define midiMsgType 0x00
  79. #define midiMgrType 0x10
  80. #define midiTimeStampMask 0x80
  81. #define midiTimeStampCurrent 0x80
  82. #define midiTimeStampValid 0x00
  83.  
  84. /*     MIDI Manager MIDIPacket command words (the first word in the data field
  85.     for midiMgrType messages) */
  86.  
  87. #define midiOverflowErr 0x0001
  88. #define midiSCCErr 0x0002
  89. #define midiPacketErr 0x0003
  90. #define midiMaxErr 0x00FF               /*all command words less than this value  are error indicators*/
  91.  
  92. /* Valid results to be returned by readHooks  */
  93.  
  94. #define midiKeepPacket 0
  95. #define midiMorePacket 1
  96. #define midiNoMorePacket 2
  97.  
  98. /*  Errors: */
  99.  
  100. #define midiNoClientErr -250            /*no client with that ID found*/
  101. #define midiNoPortErr -251              /*no port with that ID found*/
  102. #define midiTooManyPortsErr -252        /*too many ports already installed in the system*/
  103. #define midiTooManyConsErr -253         /*too many connections made*/
  104. #define midiVConnectErr -254            /*pending virtual connection created*/
  105. #define midiVConnectMade -255           /*pending virtual connection resolved*/
  106. #define midiVConnectRmvd -256           /*pending virtual connection removed*/
  107. #define midiNoConErr -257               /*no connection exists between specified ports*/
  108. #define midiWriteErr -258               /*MIDIWritePacket couldn't write to all connected ports*/
  109. #define midiNameLenErr -259             /*name supplied is longer than 31 characters*/
  110. #define midiDupIDErr -260               /*duplicate client ID*/
  111. #define midiInvalidCmdErr -261          /*command not supported for port type*/
  112.  
  113. /*      Driver calls: */
  114.  
  115. #define midiOpenDriver 1
  116. #define midiCloseDriver 2
  117.  
  118. struct MIDIPacket {
  119.     unsigned char flags;
  120.     unsigned char len;
  121.     long tStamp;
  122.     unsigned char data[249];
  123. };
  124.  
  125. typedef struct MIDIPacket MIDIPacket;
  126. typedef MIDIPacket *MIDIPacketPtr;
  127.  
  128. struct MIDIClkInfo {
  129.     short sync;                         /*synchronization external/internal*/
  130.     long curTime;                       /*current value of port's clock*/
  131.     short format;                       /*time code format*/
  132. };
  133.  
  134. typedef struct MIDIClkInfo MIDIClkInfo;
  135. struct MIDIIDRec {
  136.     OSType clientID;
  137.     OSType portID;
  138. };
  139.  
  140. typedef struct MIDIIDRec MIDIIDRec;
  141. struct MIDIPortInfo {
  142.     short portType;                     /*type of port*/
  143.     MIDIIDRec timeBase;                 /*MIDIIDRec for time base*/
  144.     short numConnects;                  /*number of connections*/
  145.     MIDIIDRec cList[];                  /*ARRAY [1..numConnects] of MIDIIDRec*/
  146. };
  147.  
  148. typedef struct MIDIPortInfo MIDIPortInfo;
  149. typedef MIDIPortInfo *MIDIPortInfoPtr, **MIDIPortInfoHdl;
  150.  
  151. struct MIDIPortParams {
  152.     OSType portID;                      /*ID of port, unique within client*/
  153.     short portType;                     /*Type of port - input, output, time, etc.*/
  154.     short timeBase;                     /*refnum of time base, 0 if none*/
  155.     long offsetTime;                    /*offset for current time stamps*/
  156.     Ptr readHook;                       /*routine to call when input data is valid*/
  157.     long refCon;                        /*refcon for port (for client use)*/
  158.     MIDIClkInfo initClock;              /*initial settings for a time base*/
  159.     Str255 name;                        /*name of the port, This is a real live string, not a ptr.*/
  160. };
  161.  
  162. typedef struct MIDIPortParams MIDIPortParams;
  163. typedef MIDIPortParams *MIDIPortParamsPtr;
  164.  
  165. struct MIDIIDList {
  166.     short numIDs;
  167.     OSType list[];
  168. };
  169.  
  170. typedef struct MIDIIDList MIDIIDList;
  171. typedef MIDIIDList *MIDIIDListPtr, **MIDIIDListHdl;
  172.  
  173. #ifdef __cplusplus
  174. extern "C" {
  175. #endif
  176.  
  177. /* 
  178.      Prototype Declarations for readHook and timeProc
  179.      
  180.      extern pascal short myReadHook(MIDIPacketPtr myPacket, long myRefCon);
  181.      extern pascal void myTimeProc(long curTime, long myRefCon);
  182.     
  183.      MIDI Manager Routines
  184. */
  185.  
  186. pascal long SndDispVersion(short toolnum); 
  187. pascal OSErr MIDISignIn(OSType clientID,long refCon,Handle icon,const Str255 name)
  188.     = {0x203C,0x0004,midiToolNum,0xA800}; 
  189. pascal void MIDISignOut(OSType clientID)
  190.     = {0x203C,0x0008,midiToolNum,0xA800}; 
  191. pascal MIDIIDListHdl MIDIGetClients(void)
  192.     = {0x203C,0x000C,midiToolNum,0xA800}; 
  193. pascal void MIDIGetClientName(OSType clientID,const Str255 name)
  194.     = {0x203C,0x0010,midiToolNum,0xA800}; 
  195. pascal void MIDISetClientName(OSType clientID,const Str255 name)
  196.     = {0x203C,0x0014,midiToolNum,0xA800}; 
  197. pascal MIDIIDListHdl MIDIGetPorts(OSType clientID)
  198.     = {0x203C,0x0018,midiToolNum,0xA800}; 
  199. pascal OSErr MIDIAddPort(OSType clientID,short BufSize,short *refnum,MIDIPortParamsPtr init)
  200.     = {0x203C,0x001C,midiToolNum,0xA800}; 
  201. pascal MIDIPortInfoHdl MIDIGetPortInfo(OSType clientID,OSType portID)
  202.     = {0x203C,0x0020,midiToolNum,0xA800}; 
  203. pascal OSErr MIDIConnectData(OSType srcClID,OSType srcPortID,OSType dstClID,
  204.     OSType dstPortID)
  205.     = {0x203C,0x0024,midiToolNum,0xA800}; 
  206. pascal OSErr MIDIUnConnectData(OSType srcClID,OSType srcPortID,OSType dstClID,
  207.     OSType dstPortID)
  208.     = {0x203C,0x0028,midiToolNum,0xA800}; 
  209. pascal OSErr MIDIConnectTime(OSType srcClID,OSType srcPortID,OSType dstClID,
  210.     OSType dstPortID)
  211.     = {0x203C,0x002C,midiToolNum,0xA800}; 
  212. pascal OSErr MIDIUnConnectTime(OSType srcClID,OSType srcPortID,OSType dstClID,
  213.     OSType dstPortID)
  214.     = {0x203C,0x0030,midiToolNum,0xA800}; 
  215. pascal void MIDIFlush(short refnum)
  216.     = {0x203C,0x0034,midiToolNum,0xA800}; 
  217. pascal ProcPtr MIDIGetReadHook(short refnum)
  218.     = {0x203C,0x0038,midiToolNum,0xA800}; 
  219. pascal void MIDISetReadHook(short refnum,ProcPtr hook)
  220.     = {0x203C,0x003C,midiToolNum,0xA800}; 
  221. pascal void MIDIGetPortName(OSType clientID,OSType portID,const Str255 name)
  222.     = {0x203C,0x0040,midiToolNum,0xA800}; 
  223. pascal void MIDISetPortName(OSType clientID,OSType portID,const Str255 name)
  224.     = {0x203C,0x0044,midiToolNum,0xA800}; 
  225. pascal void MIDIWakeUp(short refnum,long time,long period,ProcPtr timeProc)
  226.     = {0x203C,0x0048,midiToolNum,0xA800}; 
  227. pascal void MIDIRemovePort(short refnum)
  228.     = {0x203C,0x004C,midiToolNum,0xA800}; 
  229. pascal short MIDIGetSync(short refnum)
  230.     = {0x203C,0x0050,midiToolNum,0xA800}; 
  231. pascal void MIDISetSync(short refnum,short sync)
  232.     = {0x203C,0x0054,midiToolNum,0xA800}; 
  233. pascal long MIDIGetCurTime(short refnum)
  234.     = {0x203C,0x0058,midiToolNum,0xA800}; 
  235. pascal void MIDISetCurTime(short refnum,long time)
  236.     = {0x203C,0x005C,midiToolNum,0xA800}; 
  237. pascal void MIDIStartTime(short refnum)
  238.     = {0x203C,0x0060,midiToolNum,0xA800}; 
  239. pascal void MIDIStopTime(short refnum)
  240.     = {0x203C,0x0064,midiToolNum,0xA800}; 
  241. pascal void MIDIPoll(short refnum,long offsetTime)
  242.     = {0x203C,0x0068,midiToolNum,0xA800}; 
  243. pascal OSErr MIDIWritePacket(short refnum,MIDIPacketPtr packet)
  244.     = {0x203C,0x006C,midiToolNum,0xA800}; 
  245. pascal Boolean MIDIWorldChanged(OSType clientID)
  246.     = {0x203C,0x0070,midiToolNum,0xA800}; 
  247. pascal long MIDIGetOffsetTime(short refnum)
  248.     = {0x203C,0x0074,midiToolNum,0xA800}; 
  249. pascal void MIDISetOffsetTime(short refnum,long offsetTime)
  250.     = {0x203C,0x0078,midiToolNum,0xA800}; 
  251. pascal long MIDIConvertTime(short srcformat,short dstformat,long time)
  252.     = {0x203C,0x007C,midiToolNum,0xA800}; 
  253. pascal long MIDIGetRefCon(short refnum)
  254.     = {0x203C,0x0080,midiToolNum,0xA800}; 
  255. pascal void MIDISetRefCon(short refnum,long refCon)
  256.     = {0x203C,0x0084,midiToolNum,0xA800}; 
  257. pascal long MIDIGetClRefCon(OSType clientID)
  258.     = {0x203C,0x0088,midiToolNum,0xA800}; 
  259. pascal void MIDISetClRefCon(OSType clientID,long refCon)
  260.     = {0x203C,0x008C,midiToolNum,0xA800}; 
  261. pascal short MIDIGetTCFormat(short refnum)
  262.     = {0x203C,0x0090,midiToolNum,0xA800}; 
  263. pascal void MIDISetTCFormat(short refnum,short format)
  264.     = {0x203C,0x0094,midiToolNum,0xA800}; 
  265. pascal void MIDISetRunRate(short refnum,short rate,long time)
  266.     = {0x203C,0x0098,midiToolNum,0xA800}; 
  267. pascal Handle MIDIGetClientIcon(OSType clientID)
  268.     = {0x203C,0x009C,midiToolNum,0xA800}; 
  269. #ifdef __cplusplus
  270. }
  271. #endif
  272.  
  273. #endif
  274.